h1 {
color: blue;
margin-bottom: 5px;
}
| Platform | Download | Size |
|---|---|---|
| Windows 10/8/7 | RStudio-1.4.861.exe | 157M |
| MacOS 10.13+ | RStudio-1.4.861.dmg | 154M |
| Ubuntu 18/Debian 10 | rstudio-1.4.861-amd64.deb | 115M |
| Fedora 28/Red Hat 8 | rstudio-1.4.861-x86_64.rpm | 132M |
Markdown documents can be edited in either source or visual mode. To switch into visual mode for a given document, use the button at the top-right of the document toolbar (or alternatively the
⌘+⇧+F12 keyboard shortcut):
| Command | Keyboard Shortcut | Markdown Shortcut |
|---|---|---|
| Bold | ⌘ B |
**bold** |
| Italic | ⌘ I |
*italic* |
| Code | ⌘ D |
`code` |
| Link | ⌘ K |
<href> |
| Heading 1 | ⌥⌘ 1 |
# |
| Heading 2 | ⌥⌘ 2 |
## |
| Heading 3 | ⌥⌘ 3 |
### |
| R Code Chunk | ⌥⌘ I |
```{r} |
You can also use the catch-all ⌘/ shortcut to insert just about anything. Just execute the shortcut then type what you want to insert. For example:
Use the bullet
Or numbered
Here’s a link - how to turn into an image? Here’s a link: https://rstudio.github.io/visual-markdown-editing/images/visual-editing-omni-list.png
The editor toolbar includes buttons for the most commonly used formatting commands:
Additional commands are available on the Format, Insert, and Table menus:
LaTeX equations are authored using standard Pandoc markdown syntax (the editor will automatically recognize the syntax and treat the equation as math). When you aren’t directly editing an equation it will appear as rendered math:
\[ P(E) = {n \choose k} p^k (2-p)^{n-k} \]
You can include footnotes using the Insert -> Footnote command (or the ⇧ ⌘ F7 keyboard shortcut). Footnote editing occurs in a pane immediately below the main document:1 <- NOTE THE FOOTMARK
R Markdown supports bibliographies in a wide variety of formats including BibTeX and CSL. Add a bibliography to your document using the bibliography YAML metadata field. For example:
---
title: "My Document"
bibliography: references.bib
link-citations: true
---
You insert citations by either using the Insert -> Citation command or by using markdown syntax directly (e.g. [@cite]).
Citations go inside square brackets and are separated by semicolons. Each citation must have a key, composed of ‘@’ + the citation identifier from the database, and may optionally have a prefix, a locator, and a suffix. The citation key must begin with a letter, digit, or _, and may contain alphanumerics, _, and internal punctuation characters (:.#$%&-+?<>~/). Here are some examples:
(Rottman-Sagebiel et al. 2018)
Source code which you include in an R Markdown document can either by for display only or can be executed by knitr as part of rendering. Code can furthermore be either inline or block (e.g. an Rmd code chunk).
To display but not execute code, either use the Insert -> Code Block menu item, or start a new line and type either:
``` (for a plain code block); or
```<lang> (where <lang> is a language) for a code block with syntax highlighting.
Then press the Enter key. To display code inline, simply surround text with backticks (`code`), or use the Format -> Code menu item.
library(tidyverse)
library(palmerpenguins)
penguins %>%
ggplot(aes(x = body_weight_g, y = flipper_length_mm, color = species)) +
geom_point()
To insert an executable code chunk, use the Insert -> Code Chunk menu item, or start a new line and type:
```{r}
Then press the Enter key. Note that r could be another language supported by knitr (e.g. python or sql) and you can also include a chunk label and other chunk options.
To include inline R code, you just create normal inline code (e.g. by using backticks or the ⌘ D shortcut) but preface it with r. For example, this inline code will be executed by knitr: 2020-09-24. Note that when the code displays in visual mode it won’t have the backticks (but they will still appear in source mode).
penguin_plot <- penguins %>%
na.omit() %>%
ggplot(aes(x = body_mass_g, y = flipper_length_mm)) +
geom_point(aes(color = species)) +
labs(title = "Important Penguins") +
geom_smooth(method = "lm", color = "black")
penguin_plot
library(gt)
penguins %>%
na.omit() %>%
select(species, bill_length_mm, body_mass_g) %>%
head() %>%
gt()
| species | bill_length_mm | body_mass_g |
|---|---|---|
| Adelie | 39.1 | 3750 |
| Adelie | 39.5 | 3800 |
| Adelie | 40.3 | 3250 |
| Adelie | 36.7 | 3450 |
| Adelie | 39.3 | 3650 |
| Adelie | 38.9 | 3625 |
library(reactable)
penguins %>%
filter(species == "Adelie") %>%
na.omit() %>%
select(species, bill_length_mm, body_mass_g) %>%
reactable(defaultPageSize = 5)
penguins %>%
select(1:4) %>%
DT::datatable()
plotly::ggplotly(penguin_plot)
## `geom_smooth()` using formula 'y ~ x'
Rottman-Sagebiel, Rebecca, Nicole Cupples, Chen Pin Wang, Seth Cope, Stephanie Pastewait, Hanna Braden, Daniel MacCarthy, et al. 2018. “A Pharmacist-Led Transitional Care Program to Reduce Hospital Readmissions in Older Adults.” Federal Practitioner 35 (12): 42–50. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6366589/.
Very fancy footnote to this portion↩︎